<template>
	<view class="page">
		<view class="address">

			<view class="" v-if="!chec">
				<view class="get" @click="totoaddress">+点击完善收货地址</view>
			</view>

			<view class="" v-else >
				<view class="boxx" >
					<view class="bol">
						<u-checkbox-group>
							<u-checkbox :checked="show1" @click="show" >
							</u-checkbox>
						</u-checkbox-group>
					</view>
					<view class="boc" @click="show">
						<view class="boc-t">
							<span>{{dizhi.username}}</span> <span>{{dizhi.userphone}}</span> <span>{{dizhi.label}}</span>
						</view>
						<view class="boc-b">
						{{dizhi.location+dizhi.useraddress}}
						</view>
					</view>
					<view class="bor">
						<u-icon name="edit-pen-fill" size="36" @click="totoaddress"></u-icon>
					</view>
				</view>
			</view>

		</view>
		<view class="shoplist">
			<view class="top">
				<view class="">
					<u-icon name="shopping-cart-fill" color="#ff6040" size="25"></u-icon>
					<text>品牌精选</text>
				</view>
				<view class="tex">
					<text>已免运费 </text>|
					<text> 领券</text>
				</view>
			</view>

			<view class="shopdetail" v-for="item in cart" :key="item.id" >
				<!-- #ifdef H5 -->
				<view class=""><img :src="item.img" alt=""></view>
				<!-- #endif -->
				
				<!-- #ifdef MP-WEIXIN -->
				<view class=""><img :src="'http://localhost:3070'+item.img" alt=""></view>
				<!-- #endif -->
				
				<view class="">
					<view class="cart-title" >{{item.goodsname}}</view>
					<view style="color: #ff6040;font-size: 39rpx;">&yen;{{item.price}}</view>
					<view>七天无理由退货</view>
				</view>
				<view class="num">
					<text></text>
					<text>X{{item.num}}</text>
				</view>
			</view>

			

			<u-cell-group>
				<u-cell title="发票类型" :isLink="true" arrow-direction="down" value="不开发票"></u-cell>
				<u-cell title="售后免邮" :isLink="false" value="部分商家赠送"></u-cell>
				<u-cell title="卖家留言" :isLink="false" value="填写内容需要与商家协议并确认,45字以内"></u-cell>
			</u-cell-group>
		</view>
		<view class="padding">
			<u-cell-group>
				<u-cell title="商品金额" :isLink="false" arrow-direction="down" value="￥200"></u-cell>
				<u-cell title="优惠活动" :isLink="false" value="-￥200"></u-cell>
				<u-cell title="优惠券" :isLink="true" value="更多优惠券"></u-cell>
			</u-cell-group>
		</view>
		<view class="boo">

		</view>
		<view class="footer">
			<view class="">
				<text>合计</text>
				<text>已免运费</text>
			</view>
			<view class="">
				<text>&yen;{{allprice}}</text>
				<text>已优惠</text>
			</view>
			<view class="" @click="tosure">确认订单</view>
		</view>
	</view>
</template>

<script>
	import {orderadd} from '@/rquest/api.js'
	export default {
		data() {
			return {
				dizhi:[],
				show1:true,
				chec:true,
				cart:[],
				allprice:'',
				outTradeNo:''
			}
		},
		onLoad() {
			if(uni.getStorageSync('cart')){
				this.cart=uni.getStorageSync('cart')
				console.log(this.cart);
			}
			this.allprice =uni.getStorageSync('allprice')
		},
		onShow() {
			if(uni.getStorageSync('dizhi')){
				this.dizhi =uni.getStorageSync('dizhi')
				this.chec =true;
				console.log(this.dizhi);
			}else{
				this.chec =false
			}
		},
		methods: {
			totoaddress() {
				uni.navigateTo({
					url: '../toaddress/toaddress'
				})
			},
			
			// 确认订单
			tosure() {
				let bb=new Date().getTime().toString()
				// console.log(uni.getStorageSync("user").uid);
				// console.log(uni.getStorageSync('allprice').toFixed(2));
				// console.log(uni.getStorageSync('allnum'));
				// console.log(uni.getStorageSync("dizhi").id);
				// console.log(bb);
				
				
				// ============================================================================
				orderadd({
					uid: uni.getStorageSync("user").uid,
					countmoney:uni.getStorageSync('allprice').toFixed(2),
					countnumber:uni.getStorageSync('allnum'),
					addressid:uni.getStorageSync("dizhi").id,
					idstr:'1,'+bb
				}).then(res=>{
					console.log(11111111,res);
					uni.setStorageSync('outTradeNo',res.data.list.outTradeNo)
				}).catch(err=>{
					console.log(err);
				})
				// ============================================================================
				
				uni.navigateTo({
					url: '../sure/sure'
				})
			},
			show(){
				this.show1=!this.show1
			}
		}
	}
</script>

<style>
	.cart-title{
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	
	}
	.u-cell__title-text.data-v-1c4434ae {

		line-height: 30px !important;

	}

	.shopdetail view:nth-of-type(2) view:nth-of-type(3) {
		width: 60% !important;
		height: 42rpx !important;
		background-color: #ff6040;
		text-align: center;
		line-height: 42rpx !important;
		color: #FFF;
		border-radius: 50rpx;
	}

	.boo {
		height: 100px;
	}

	.tex {
		font-size: 30rpx;
	}

	.tex text:nth-child(2) {
		color: #ff6040;
	}

	.u-cell__value.data-v-1c4434ae {
		font-size: 30rpx !important;
	}

	.address {
		background-color: whitesmoke;
		margin: 0px auto;
		height: 200rpx;
		padding-top: 1rpx;
		box-sizing: border-box;
	}

	.get {
		width: 50%;
		margin: 60rpx auto;
		background-color: #FFF8DC;
		border: 1px solid orange;
		text-align: center;
		line-height: 80rpx;
		color: orange;
		border-radius: 20rpx;
	}

	.shoplist {
		height: auto;
		background-color: #fff;
		padding: 0px 5%;
		box-sizing: border-box;
	}

	.top {
		height: 20%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 16rpx 0px;
	}

	.top view:nth-of-type(1) {
		display: flex;
	}

	.shopdetail view:nth-of-type(1) img {
		width: 200rpx;
		height: 200rpx;
	}

	.shopdetail {
		padding: 6rpx 0px;
		margin-bottom: 20rpx;
		display: flex;
		justify-content: space-around;
	}

	.shopdetail view:nth-of-type(2) {
		display: flex;
		flex-direction: column;
		justify-content: space-evenly;
	}

	.shopdetail view:nth-of-type(2) view:nth-of-type(3) {
		width: 100%;
		height: 100rpx;
		background-color: #ff6040;
		text-align: center;
		line-height: 100rpx;
		color: #FFF;
	}

	.num {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.u-cell__body.data-v-1c4434ae {
		padding: 0px 0px !important;
	}

	.u-cell-group.data-v-7369b029 {
		margin-top: 40rpx !important;
	}

	.u-cell__title-text.data-v-1c4434ae {
		font-size: 40rpx;
		font-weight: bold;
	}

	.padding {
		padding: 0px 5%;
		box-sizing: border-box;
		background-color: #fff;
	}

	.footer {
		width: 100%;
		height: 100rpx;
		background-color: #fff;
		position: fixed;
		bottom: 0px;
		display: flex;
		justify-content: space-between;
	}

	.footer view:nth-of-type(1),
	.footer view:nth-of-type(2) {
		display: flex;
		flex-direction: column;
		padding-left: 30rpx;
		box-sizing: border-box;
		justify-content: space-between;
	}

	.footer view:nth-of-type(3) {
		width: 40%;
		height: 100%;
		background-color: #ff6040;
		text-align: center;
		line-height: 100rpx;
		color: #FFF;
	}

	.page {
		background-color: whitesmoke !important;
	}

	.bol {
		padding: 10rpx;
		box-sizing: border-box;
	}

	.boxx {
		margin: 30rpx auto;
		display: flex;
		width: 90%;
		border-radius: 10rpx;
		background-color: #fff;
		padding: 20rpx;
		align-items: center;
		border-radius: 39rpx;

	}

	.bor {
		box-sizing: border-box;
		text-align: center;
	}

	.boc-t {
		font-weight: bold;
		display: flex;
		justify-content: left;
	}

	.boc-t span {
		display: block;
		margin-right: 30rpx;
	}

	.boc-t span:nth-child(3) {

		background-color: #FF6040;
		padding: 0px 10rpx;
		border-radius: 9rpx;
		color: #fff;

	}

	.boc {
		width: 80%;
		box-sizing: border-box;
		line-height: 60rpx;
	}
</style>
